import React, { useState } from "react";
import { insert } from "../../services/student";
import InputElement from "../InputElement";
import RadioElement from "../RadioElement";
export default function (props) {
    
    let [name,setName] = useState("");
    let [age,setAge] = useState(0);
    let [gender,setGender] = useState("");

    const handleClick = async () => {
        console.log(name,age,gender);
        await insert({name,age,gender});
        props.show();
    }
    return (
        <div>
            <h2>增加</h2>
            <InputElement onInput={e => setName(e.target.value)}>姓名：</InputElement>
            <InputElement onInput={e => setAge(e.target.value)}>年龄：</InputElement>
            <RadioElement value={gender} onChange={e => setGender(e.target.value)} name="addGender">性别：</RadioElement>
            <input type="button"  value="增加" onClick={handleClick} />
        </div>
    );
}
